package com.tarena.seata.web.rpc;

import com.tarena.seata.api.StockApi;
import com.tarena.seata.web.mapper.StockMapper;
import io.seata.core.context.RootContext;
import io.seata.spring.annotation.GlobalTransactional;
import java.util.Random;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class StockApiImpl implements StockApi {
    @Autowired
    private StockMapper stockMapper;
    @GlobalTransactional
    @Override public void reduceStock(String productCode, Integer count) {
        System.out.println("seata全局事务id=============="+ RootContext.getXID());
        stockMapper.updateStockCountByProducerCode(productCode,count);

    }
}
